From 0ae3a2b4fb2c76ba30ec80740fb9cbc2d0a7ae3a Mon Sep 17 00:00:00 2001 From: Andy Russell Date: Wed, 16 Nov 2016 14:31:06 -0500 Subject: [PATCH] remove current_package from context --- src/cargo/ops/cargo_rustc/context.rs | 13 ++++++------- src/cargo/ops/cargo_rustc/job_queue.rs | 4 ++-- src/cargo/ops/cargo_rustc/mod.rs | 4 ++-- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/cargo/ops/cargo_rustc/context.rs b/src/cargo/ops/cargo_rustc/context.rs index de90ba89b..c53ce6040 100644 --- a/src/cargo/ops/cargo_rustc/context.rs +++ b/src/cargo/ops/cargo_rustc/context.rs @@ -29,9 +29,9 @@ pub struct Unit<'a> { } pub struct Context<'a, 'cfg: 'a> { + pub ws: &'a Workspace<'cfg>, pub config: &'cfg Config, pub resolve: &'a Resolve, - pub current_package: Option, pub compilation: Compilation<'cfg>, pub packages: &'a PackageSet<'cfg>, pub build_state: Arc, @@ -60,7 +60,7 @@ struct TargetInfo { pub struct Metadata(u64); impl<'a, 'cfg> Context<'a, 'cfg> { - pub fn new(ws: &Workspace<'cfg>, + pub fn new(ws: &'a Workspace<'cfg>, resolve: &'a Resolve, packages: &'a PackageSet<'cfg>, config: &'cfg Config, @@ -76,12 +76,11 @@ impl<'a, 'cfg> Context<'a, 'cfg> { None => None, }; - let current_package = ws.current_opt().map(Package::package_id).cloned(); Ok(Context { + ws: ws, host: host_layout, target: target_layout, resolve: resolve, - current_package: current_package, packages: packages, config: config, target_info: TargetInfo::default(), @@ -450,8 +449,8 @@ impl<'a, 'cfg> Context<'a, 'cfg> { // we don't want to link it up. if src_dir.ends_with("deps") { // Don't lift up library dependencies - if self.current_package.as_ref().map_or(false, |p| unit.pkg.package_id() != p) - && !unit.target.is_bin() { + if self.ws.current_opt().map_or(false, |p| unit.pkg.package_id() != p.package_id()) + && !unit.target.is_bin() { None } else { Some(( @@ -837,7 +836,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> { } pub fn show_warnings(&self, pkg: &PackageId) -> bool { - self.current_package.as_ref().map_or(false, |p| *pkg == *p) + self.ws.current_opt().map_or(false, |p| *pkg == *p.package_id()) || pkg.source_id().is_path() || self.config.extra_verbose() } diff --git a/src/cargo/ops/cargo_rustc/job_queue.rs b/src/cargo/ops/cargo_rustc/job_queue.rs index 6ddd002f8..5e35a7e10 100644 --- a/src/cargo/ops/cargo_rustc/job_queue.rs +++ b/src/cargo/ops/cargo_rustc/job_queue.rs @@ -198,8 +198,8 @@ impl<'a> JobQueue<'a> { } let build_type = if self.is_release { "release" } else { "debug" }; - let profile = cx.current_package.as_ref().map_or_else(Profile::default, |p| { - cx.lib_profile(p).to_owned() + let profile = cx.ws.current_opt().map_or_else(Profile::default, |p| { + cx.lib_profile(p.package_id()).to_owned() }); let mut opt_type = String::from(if profile.opt_level == "0" { "unoptimized" } else { "optimized" }); diff --git a/src/cargo/ops/cargo_rustc/mod.rs b/src/cargo/ops/cargo_rustc/mod.rs index 0abfe4986..dff80e493 100644 --- a/src/cargo/ops/cargo_rustc/mod.rs +++ b/src/cargo/ops/cargo_rustc/mod.rs @@ -557,8 +557,8 @@ fn build_base_args(cx: &mut Context, let prefer_dynamic = (unit.target.for_host() && !unit.target.is_custom_build()) || (crate_types.contains(&"dylib") && - cx.current_package.as_ref().map_or(false, |p| { - *p != *unit.pkg.package_id() + cx.ws.current_opt().map_or(false, |p| { + *p.package_id() != *unit.pkg.package_id() })); if prefer_dynamic { cmd.arg("-C").arg("prefer-dynamic"); -- 2.30.2